import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const state = {
  //读取本地
  userinfo: JSON.parse(localStorage.getItem('userinfo'))

}
//console.log(state.userinfo)


//操作state
const mutations = {
  //保存用户数据
  SAVE_USERINFO(state, userinfo) {
    //c存入本地
    localStorage.setItem('userinfo', JSON.stringify(userinfo))
    state.userinfo = userinfo
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions: {},
  modules: {}
});
